package cn.sh.ideal.yedis;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import cn.sh.ideal.yedis.builder.RedisBuilder;
import cn.sh.ideal.yedis.builder.RedisSentinelBuilder;
import cn.sh.ideal.yedis.builder.RedisStandaloneBuilder;
import cn.sh.ideal.yedis.core.RedisTemplate;
import redis.clients.jedis.JedisPoolConfig;

public class Test {
	public static void main(String[] args) throws InterruptedException {

		testHash();
		//test1();

		//testSset();
		//testPub();
		//testpipelineset();
		//testpipelineget();
	}

	public static void test1() throws InterruptedException {
		
	}


	public static void testHash() throws InterruptedException{
		JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
		jedisPoolConfig.setMaxTotal(-1);
		jedisPoolConfig.setMaxIdle(20);
		jedisPoolConfig.setMaxWaitMillis(3000);
		//RedisStandaloneBuilder rsb = RedisBuilder.redisStandalone("172.31.21.3:6379");
		RedisSentinelBuilder rsb = RedisBuilder.redisSentinel("172.31.21.3:26379", "mymaster");
		//rsb.setPassword("ideal");
		rsb.setPoolConfig(jedisPoolConfig);
		rsb.setSoTimeout(3000);
		rsb.setTimeout(3000);
		final RedisTemplate template = new RedisTemplate<>();
		template.setBuilder(rsb).init();
		System.out.println(template.getOperation().incr("aa"));
		/*int total = 0;
		List<Long> list = new ArrayList<>();
		Set<String> keys = template.getOperation().keys("receicecount:*");
		for(String key : keys) {
			long count = template.getOperation().counter(key);
			total += count;
			list.add(count);
		}
		
		int size = list.size();
		Collections.sort(list);
		System.out.println("size:" + size + ",min:" + list.get(0) + ",max:" + list.get(size-1) + ",avg:" + total/size);
		*/
	}
		
}



